#include "widget.h"
#include "ui_widget.h"
#include <QLineEdit>


Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    //编译器实现
    //QLineEdit* edit=new QLineEdit(this);
    //edit->setText("hello qt!!");

    //按钮实现
    button=new QPushButton(this);
    button->setText("hello qt!!");
    button->move(300,300);//设置按钮位置,单位是像素点

    connect(button,&QPushButton::clicked,this,&Widget::handleClick);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::handleClick()
{
    if(button->text()=="hello qt") button->setText("切换");
    else button->setText("hello qt");
}

